#!/bin/bash
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
yum install jenkins -y


# jenkins相关目录释义： rpm -ql jenkins
# 1，/usr/lib/jenkins/：jenkins安装目录，war包会放在这里。
# 2， /etc/sysconfig/jenkins：jenkins配置文件，“端口”，“JENKINS_HOME”等都可以在这里配置。
# 3，/var/lib/jenkins/：默认的JENKINS_HOME。
# 4，/var/log/jenkins/jenkins.log：jenkins日志文件。
nohup java -jar /usr/lib/jenkins/jenkins.war --httpPort=8080 >/dev/null &
# /root/.jenkins
# 查看管理员密码
echo "管理员密码："
cat /root/.jenkins/secrets/initialAdminPassword

# ============================== 换国内地址，插件 ============================== 
# (0)界面上操作：Manage Jenkins/Plugin Manager/Available 标签下，执行 Install without restart
# (1)容器内替换国内地址 https://updates.jenkins-zh.cn/update-center.json
# cd /var/jenkins_home/updates/
# sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
# (2)界面上操作：Manage Jenkins/Plugin Manager/Advanced 标签，拖到最下换国内地址
# https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
# (1)重启
# http://192.168.56.101:8080/restart

# 插件：chim
# Chinese (Simplified)
# Role-based Authorization Strategy
# Credentials Binding Plugin
# git
# jenkins私钥，gogs 公钥
# ssh-keygen -t rsa

